<?php
require_once("../../config.php");
//require_once($config_rootdir."/php/dao/hero/heroDAO.php");
require_once($config_rootdir."/php/service/enemy/enemyService.php");
require_once($config_rootdir."/php/service/hero/heroService.php");

//$hero = findHeroByUserId(1);
$_SESSION["userId"] = 1;

//echo $hero["id"];

session_start();

function init() {
//	$hero = findHeroByUserId($_SESSION["userId"]);
/*
	$character = getCharacterByPlayerId($_SESSION["playerId"]);
*/
	$_SESSION["heroState"] = "combat";
	$_SESSION["enemyHP"] = 100;
	$hero["level"] = 1;
	$_SESSION["enemyLevel"] = enemyService_diceEnemyLevel($hero["level"]);
	$_SESSION["enemy"] = enemyService_findRandomByLevel(1);
}

function fight() {
	dice();
	if (WINNER) {
	}
	else {
	}
}

function run() {
	dice();
	if (SUCCESS) {
		$_SESSION["state"] = "normal";
	}
	else {
	}
}

function execute() {
	if (!isset($_SESSION["heroState"]) || $_SESSION["heroState"] == "normal") {
		init();
	}
	else
	if ($_REQUEST["action"] == "fight") {
		fight();
	}
	else
	if ($_REQUEST["action"] == "run") {
		run();
	}
}

execute();
echo $_SERVER["DOCUMENT_ROOT"];
?>

hola mundo
